package dbb

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/widget"
	"github.com/gogf/gf/v2/database/gdb"
)

func ddl(db gdb.DB, tbl string) fyne.CanvasObject {
	// if v, err := bdddl.Get(); err != nil || v == "" {
	// 	return widget.NewLabel("no table in the db")
	// }
	txt := widget.NewMultiLineEntry()
	txt.Bind(bdddl)
	return container.NewBorder(nil, nil, nil, nil, txt)
}
func setddl(db gdb.DB, tbl string) {
	xdb := gf2xorm(db)
	tbls, _ := xdb.DBMetas()
	if len(tbls) == 0 {
		bdddl.Set("")
	}
	for _, t := range tbls {
		if t.Name != tbl {
			continue
		}
		str, _, _ := xdb.Dialect().CreateTableSQL(Me.Ctx, nil, t, tbl)
		bdddl.Set(str)
		// bdddl.Set(strings.Join(strings.Split(str[0], ","), ",\n"))
	}
}
